package com.ewanghuiju.app.ui.shopmail.adapter;

import android.graphics.Paint;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.component.ImageLoader;
import com.ewanghuiju.app.model.bean.response.MailShopResponBean;
import com.ewanghuiju.app.util.StringUtil;
import com.makeramen.roundedimageview.RoundedImageView;

/**
 * @author sj  qq:751943509
 * @class 优惠券板块 商品信息
 * @time 2020/2/20
 */
public class MailShopAdapter extends BaseQuickAdapter<MailShopResponBean, BaseViewHolder> {
    public MailShopAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    protected void convert(BaseViewHolder helper, MailShopResponBean item) {
        TextView tv_title = helper.getView(R.id.tv_shop_title);
        StringUtil.getTextStrFormat(tv_title, "AA", item.getTitle());
        helper.setText(R.id.tv_spe_price, item.getPrice() + "");
        helper.setText(R.id.tv_buynum, item.getVolume() + "人购买");
//        helper.setText(R.id.iv_title_icon, item.getTuansum() == 0 ? "" : item.getTuansum() + "人团");
        TextView tv_yuan = helper.getView(R.id.tv_yuan_price);
        tv_yuan.setText("￥" + item.getZk_final_price());
        if (!TextUtils.isEmpty(item.getCoupon_amount())) {
            helper.setText(R.id.tv_yhq, item.getCoupon_amount() + "元券");
        }
        if (!TextUtils.isEmpty(item.getYj_zg())) {
            helper.setVisible(R.id.tv_ygz, true);
            helper.setText(R.id.tv_ygz, "预估赚 ￥" + item.getYj_zg());
        }
        if (!TextUtils.isEmpty(item.getYj_sj())) {
            helper.setVisible(R.id.tv_sjz, true);
            helper.setText(R.id.tv_sjz, "升级赚 ￥" + item.getYj_sj());
        }
        tv_yuan.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
        RoundedImageView riv = helper.getView(R.id.riv_item_icon);
        ImageView iv_lab = helper.getView(R.id.iv_lab);
        if (item.getUser_type() == 1) {
            iv_lab.setImageResource(R.mipmap.icon_tianmao_small);
        } else {
            iv_lab.setImageResource(R.mipmap.icon_taobao_small);
        }
        ImageLoader.load(mContext, item.getPict_url(), riv);
//        Glide.with(mContext).load(item.getPict_url()).optionalFitCenter().into(riv);
//        ImageLoader.load(mContext, item.getImg(), riv);
//        ImageLoader.loadImage(mContext, item.getStatus()==0?R.mipmap.icon_taobao_small:R.mipmap.icon_tianmao_small, iv_lab);
//        Glide.with(mContext).load(item.getImg()).into(riv);
    }
}
